package com.own.core.html.table;


import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.GridView;
import org.apache.wicket.markup.repeater.data.IDataProvider;

/**
 * page for demonstrating the gridview componnet
 * 
 * @author igor
 */
public class GridViewPage extends BasePage
{
    /**
     * Constructor
     */
    public GridViewPage()
    {
        IDataProvider dataProvider = new ContactDataProvider();
        GridView gridView = new GridView("rows", dataProvider)
        {
            protected void populateItem(Item item)
            {
                final Contact contact = (Contact)item.getModelObject();
                item.add(new Label("firstName", contact.getFirstName() + " " +
                        contact.getLastName()));
            }

            protected void populateEmptyItem(Item item)
            {
                item.add(new Label("firstName", "*empty*"));
            }
        };

        gridView.setRows(4);
        gridView.setColumns(3);

        add(gridView);
        add(new PagingNavigator("navigator", gridView));
    }
}